﻿#共享库设置生成lib文件
set(BUILD_SHARED_LIBS true)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true)
#或者
#set_property(TARGET sharelib PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS true)


add_library(sharelib SHARED "sharelib.cpp" "sharelib.h")

#将dll文件生成到主运行目录
SET_TARGET_PROPERTIES(sharelib PROPERTIES LINKER_LANGUAGE C
        RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}"
        LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}"
        OUTPUT_NAME "sharelib"
        PREFIX "")